<?php

// phpMyRealty 3
//
// File Name: favorites.php
// File Location : ./
//
// Copyright (c)2009 phpMyRealty.com
//
// e-mail: support@phpMyRealty.com

// Include configuration file and general functions
define('PMR', 'true');

include ( './config.php' );
include ( PATH . '/defaults.php' );

$id = str_replace('?file_dir=undefined', '', $_GET['id']);
if (!eregi('^[0-9]+$', $id)) die();

// Generate the XML feed of the gallery pictures for a definite listing
echo '<?xml version="1.0" encoding="utf-8"?>';
echo '
<pics>
';

if (file_exists( PATH . '/images/' . $id . '.jpg'))
 echo ' <pic src="' . URL . '/images/' . $id . '.jpg?rand=' . rand(0,99999). '" title="Main Image" />' . "\n";

$sql = 'SELECT * FROM ' . GALLERY_TABLE . ' WHERE listingid = "' . $id . '" ORDER BY id';
$r_gallery = $db->query( $sql ) or error ('Critical Error', mysql_error ());

if ($db->numrows($r_gallery) > 0) {
 while ($f_gallery = $db->fetcharray($r_gallery)) {
  echo ' <pic src="' . URL . '/gallery/' . $f_gallery['id'] . '.jpg?rand=' . rand(0,99999). '" title="'. $f_gallery['title'].'" />' . "\n";
 }
}

echo '</pics>';

?>